package com.itheima.dao;

import com.itheima.pojo.Admin;
import com.itheima.pojo.Role;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

public interface AuthDao extends Mapper<Admin> {

    /**
     * 根据管理员姓名获取管理列表ids
     * @param name
     * @return
     */
    @Select("select r.* from t_admin a,t_role r where a.role_uid=r.uid and a.user_name=#{username}")
    @Results({
            @Result( column = "role_name",
                    property = "roleName"),
            @Result( column = "create_time",
                    property = "createTime"),
            @Result( column = "update_time",
                    property = "updateTime"),
            @Result( column = "category_menu_uids",
                    property = "categoryMenuUids")
    })
    public Role getCategoryMenuUids(@Param("username") String name);
}
